<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8" />
    <title>新增场景</title>
    <link rel="stylesheet" type="text/css" media="all" href="/layui/css/layui.css"/>
    <script type="text/javascript" src="/layui/layui.all.js"></script>
    <script type="text/javascript" src="/js/jquery.min.js"></script>
    <script type="text/javascript" src="/js/myJs.js"></script>

</head>
<body>
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
    <legend>新增场景</legend>
</fieldset>

<div class="layui-container">
    <!--6/12 布局-->
    <div class="layui-row">
        <div class="layui-col-xs6">
            <form id="Sceneform" class="layui-form layui-form-pane"><br/><br/><br/>
                <!--服务名-->
                <div class="layui-form-item">
                    <label class="layui-form-label ">场景名称</label>
                    <div class="layui-input-inline" style="width: 300px;">
                        <input type="text" name="name" autocomplete="off" class="layui-input" />
                    </div>
                </div>

                <!--负责人-->
                <div class="layui-form-item">
                    <label class="layui-form-label ">建立人</label>
                    <div class="layui-input-inline" style="width: 300px;">
                        <input type="text" name="leader" autocomplete="off"  class="layui-input" />
                    </div>
                </div>
                <!---是否启用-->
                <div class="layui-form-item">
                    <label class="layui-form-label">是否启用</label>
                    <div class="layui-input-block">
                        <input type="checkbox" name="eStatus" lay-skin="switch" checked="checked" value="on" />
                    </div>
                </div>
                <!--<div class="layui-form-item">-->
                    <!--<label class="layui-form-label ">分类设定:</label>-->
                    <!--<div  class="layui-input-inline" style="width: 300px;">-->
                        <!--<div class="layui-form">-->
                            <!--<select name="module" id="moduleSelect">-->
                                <!--<option value="未知">请选择模块</option>-->
                            <!--</select>-->
                        <!--</div>-->
                    <!--</div>-->
                <!--</div>-->
                <!--模块-->
                <div class="layui-form-item">
                    <label class="layui-form-label" >模块</label>
                    <div class="layui-input-inline" style="width: 300px;">
                        <datalist id="modulelist">
                            <option label="我打" value="我打" />
                            <option label="记返费" value="记返费" />
                            <option label="周薪薪" value="周薪薪" />
                        </datalist>
                        <input type="text" list="modulelist" placeholder="" name="module" autocomplete="off" class="layui-input"/>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label" >环境选择</label>
                    <div class="layui-input-inline" style="width: 300px;">
                        <datalist id="envselect">
                            <option label="sit" value="sit" />
                            <option label="uat" value="uat" />
                        </datalist>
                        <input type="text" list="envselect" placeholder="" name="env" autocomplete="off" class="layui-input"/>
                    </div>
                </div>
                <div class="layui-form-item layui-form-text">
                    <label class="layui-form-label" style="width: 410px">场景描述</label>
                    <div class="layui-input-block">
                        <textarea placeholder="简单描述..." name="explain" style="height: 150px;width: 410px;" class="layui-textarea"></textarea>
                    </div>
                </div>

                <div class="layui-form-item layui-form-text">
                    <label class="layui-form-label" style="width: 410px">数据矫正</label>
                    <div class="layui-input-block">
                        <textarea name="script" placeholder="数据还原...." style="height: 150px;width: 410px;" class="layui-textarea"></textarea>
                    </div>
                </div>
                <!--备注-->
                <br/>
                <!--提交按钮-->
                <button type="button" style="width: 410px" class="layui-btn" lay-filter="add" id="add" lay-submit="">提交</button>
            </form>
        </div>
    </div>
</div>


</body>
<script>
    function loadPage(url) {
        window.location.href = url;
    }

    layui.use('form', function () {
        var form = layui.form;
        form.render();
        //监听提交
        form.on('submit(add)', function (data) {

            var from = $("#Sceneform");
            var model = serializeObject(from);

            $.ajax({
                type: "post",
                url: "/api/scene/addScene",
                contentType: "application/json; charset=utf-8",
                data: JSON.stringify(model),
                dataType: "json",
                success: function (data) {
                    if (data == "true") {
                        layer.confirm('新建成功', function (index) {
                            window.close();
                        });
                    }else {
                        layer.alert("新建失败")
                    }
                }
            })
            return false;
        });
    });
</script>
</html>